<template>
<div style="width: 100%">
  <a-card :bordered="false" class="card">
    <a-table
      :columns="columns"
      :dataSource="data"
      :loading="loading"
      :pagination="false"
      ref="table"
      rowKey="key"
      size="default"
    >
      <template slot="action" slot-scope="text,record">
        <a   :style="record.sfsb ==1?'':'color:#999'" @click="record.sfsb ==1 && handlePreview(record.dwh)">导出pdf</a>
      </template>

      <span slot="serial" slot-scope="text, record, index">
        {{ index + 1 }}
      </span>
    </a-table><!-- 编辑 -->
    <!-- <query-detail @close="handlePreviewClose" :info="preViewData"  :previewVisible="previewVisible"></query-detail> -->
  </a-card>
</div>
</template>

<script>
  // import moment from 'moment'
  // import QueryDetail from './queryDetail'
  import {STable} from '~'
  import {mapState} from 'vuex'

  const selectArr = ['TYPE0126', 'TYPE0075', 'TYPE0125', 'TYPE0072']

export default {
  components: {
    STable
  },
  data () {
    return {
      loading: false,
      data: [],
      // 查询参数
      postParams: {},
      // 表头
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '院系码',
          dataIndex: 'dwh'
        },
        {
          title: '院系名称',
          dataIndex: 'dwmc'
        },
        {
          title: '操作',
          dataIndex: 'cz',
          fixed: 'right',
          width: 120,
          scopedSlots: { customRender: 'action' }
        }
      ],
      previewVisible: false,
      selectMenu: {
        yx: [] // 院系
      },
      preViewData: {},
      zsxn:''
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
    this.initSelectMenu()
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
  },
  methods: {
    initSelectMenu () {
      let allRequest = [
        this.$api.base.collegeAll()
      ]
      Promise.all(allRequest).then(res => {
        this.selectMenu = {
          yx: res[0].data
        }
         // 获取当前学年
        this.$api.base.getSchoolYear().then(res=>{
            this.zsxn = res.data.masterAdmissionYear
            this.loadData()
        })
      })
    },
      // 加载数据
    loadData() {
      this.loading = true;
      this.$api.recruitstat.bsmenuTotalList().then(res => {
        // console.log(res)
        this.data = []
        if (res.data && res.data.length) {
          this.data = res.data;
        }
        this.loading = false;
      })
    },
    // 分页
    // handleTableChange(pagination, filters, sorter) {
    //   console.log(pagination);
    //   const pager = { ...this.pagination
    //   };
    //   pager.current = pagination.current;
    //   this.pagination = pager;
    //   this.loadData({
    //     pageSize: 10,
    //     pageNum: pagination.current
    //   });
    // },
    // 选择院系
    yxChange (code) {
    },
    // 导出pdf
    handlePreview (key) {
        let parmas ={
            ssyxm : key,
            zsxn  : this.zsxn
        }
       this.$export('admissions/zsBsszszyml/exportPdf', parmas)
    },
    // 关闭查看明细弹层
    handlePreviewClose () {
      this.previewVisible = false
      this.loadData({
        pageSize:10,
        pageNum:this.pagination.current
      })
    },
    // 导出
    // handleExport () {
    //   console.log('导出')
    //   this.$export('admissions/zsmlcx/export', this.queryParam)
    // },
    // handleExportPdf(){
    //   this.$export('admissions/zsmlcx/exportPDF', this.queryParam)
    // }
  }
}
</script>

<style lang="less" scoped>
.card{
  margin-bottom: 20px;
}
</style>
